﻿using System;
using System.IO;
using YArchitech.LIB;
using YArchitech.MEP.Electric.Common;

namespace YArchitech.Revit.MEP.Calculator
{
	public class BuildingPlaceCommon
	{
		public static string GetTemplateDbFile()
		{
			return Path.Combine(Product.DataLocation, "ElectricalData", "IllStandard.db3");
		}

		public static string GetDbFile()
		{
			string text = Path.Combine(Product.WorkingLocation, "IllStandard.db3");
			if (!File.Exists(text))
			{
				string templateDbFile = BuildingPlaceCommon.GetTemplateDbFile();
				if (!File.Exists(templateDbFile))
				{
					return string.Empty;
				}
				File.Copy(templateDbFile, text);
			}
			else
			{
				string templateDbFile2 = BuildingPlaceCommon.GetTemplateDbFile();
				if (!DataBaseTempFileOperate.IsSameVersion(templateDbFile2, text))
				{
					File.Copy(templateDbFile2, text, true);
				}
			}
			return text;
		}
	}
}
